#define  _CRT_SECURE_NO_WARNINGS 1

#include <stdio.h>

int My_Year(int a)
{
    if (a % 4 != 0)
    {
        return 0;
    }
    else
    {
        if (a % 100 != 0 || a % 400 == 0)
        {
            return 1;
        }
        else
        {
            return 0;
        }
    }
}
int main()
{
    int year = 0, month = 0, days = 0;
    int month_days[13] = { 0, 31, 59, 90, 120, 151,
                           181, 212, 243, 273, 304,
                           334, 365 };
    scanf("%d %d %d", &year, &month, &days);
    if (My_Year(year))
    {
        if (month > 2)
        {
            printf("%d\n", month_days[month - 1] + days + 1);
        }
        else
        {
            printf("%d\n", month_days[month - 1] + days);
        }
    }
    else
    {
        printf("%d\n", month_days[month - 1] + days);
    }

    return 0;
}